<template>
  <page-header-wrapper>
    <s-table
      ref="table"
      :loading="loading"
      :pageSize="pagesize"
      :columns="columns"
      :data="listData"
    >
      <span slot="action" slot-scope="text, record">
        <template>
          <a @click="pass(record)">通过</a>
          <a-divider type="vertical" />

          <a @click="refuse(record)">拒绝</a>
        </template>
      </span>
    </s-table>
  </page-header-wrapper>
</template>

<script>
import { STable } from '@/components'
import { getAdminCheckList } from '@/api/manage'

export default {
  name: 'TableList',
  components: {
    STable
  },
  data () {
    return {
      loading: false,
      pagesize: 20,
      searchText: '',
      listData: parameter => {
        this.loading = true
        return getAdminCheckList(Object.assign(parameter))
          .then(res => {
            this.loading = false
            return res.data
          })
      },
      // 表头
      columns: [
        {
          title: '学校名称',
          dataIndex: 'schoolName'
        },
        {
          title: '姓名',
          dataIndex: 'adminName'
        },
        {
          title: '手机号',
          dataIndex: 'phone'
        },
        {
          title: '申请时间',
          dataIndex: 'createTime'
        },
        {
          title: '审批',
          dataIndex: 'action',
          width: '250px',
          scopedSlots: { customRender: 'action' }
        }
      ]
    }
  },
  created () {
  },
  methods: {
    pass (item) {
      this.loading = true
      this.fetchList('/adminSchool/pass', item).then(data => {
        this.$refs.table.refresh(true)
      })
    },
    refuse (item) {
      this.loading = true
      this.fetchList('/adminSchool/refuse', item).then(data => {
        this.$refs.table.refresh(true)
      })
    }
  }
}
</script>
